package day6;

import java.util.*;

//测试集合遍历
public class TestIterate {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        Set<String> set=new HashSet<>();
        Map<String,String> map=new HashMap<>();
        list.add("html");
        list.add("css");
        list.add("js");
        list.add("vue");
        list.add("axios");
        System.out.println("标准for-----------");
        for(int i=0;i<list.size();i++){
            String s=list.get(i);
            System.out.println(s);
        }
        System.out.println("增强for(迭代器)-----------");
        for(String s:list){
            System.out.println(s);
            //list.remove(s);  出现并发修改异常
        }
        System.out.println("迭代器------------");
        Iterator<String> it=list.iterator();
        while(it.hasNext()){
            String s=it.next();
            System.out.println(s);
            //list.remove(s); 出现并发修改异常
            if("vue".equals(s)) it.remove();
        }
        list.remove("js");
        System.out.println(list);
    }
}
